package com.zsj.comminlibrary.base;

import android.app.Activity;
import android.content.Context;

import com.zsj.comminlibrary.util.log.XLog;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import androidx.multidex.MultiDexApplication;

public class BaseApplication extends MultiDexApplication {
    private static Context sContext;

    public static List<Activity> sActivities;

    @Override
    public void onCreate() {
        super.onCreate();
        sContext = this;
        sActivities = new ArrayList<>();
        BaseActivityObserver observer = new BaseActivityObserver();
        registerActivityLifecycleCallbacks(observer);
        XLog.init(this, true, false, "base" + File.separator + "log");
    }

    public static Context getContext() {
        return sContext;
    }

    public static void addActivity(Activity activity) {
        sActivities.add(activity);
    }

    public static void removeActivity(Activity activity) {
        sActivities.remove(activity);
    }
}
